package com.xiaoy.core.side.action;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.web.Servlets;

import com.xiaoy.core.side.entity.Side;
import com.xiaoy.core.side.entity.SideType;
import com.xiaoy.core.side.service.SideSerivce;
import com.xiaoy.web.BasicAction;
@Namespace("/side")
@Results( {
	@Result(name = "error", location = "/WEB-INF/content/workspace/exception.jsp", type = "dispatcher"),
})
public class SideAction extends BasicAction {

	
	@Autowired
	private SideSerivce sideService;
	
	
	public  String index () {
		
		System.out.println("side.index");
		return "index";
	}
	
	public String save () {
		sideService.save(side);
		return "save";
	}
	public String saveType() {
	
		sideService.saveType(sideType);
		return "save";
	}
	
	public String add () {
		
		request.setAttribute("types", sideService.getSideTypes());
		
		return "add";
	}
	
	public String addType () {
		return "addType";
	}
	
	
	public String list () {
		System.out.println("-------------------");
		Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_");
		List<Side> sides = sideService.search(searchParams);
		System.out.println(sides);
		request.setAttribute("lists", sides);
		return "list";
	}
	
	
	//------------------------------------------
	private Side side;
	private SideType sideType;

	public Side getSide() {
		return side;
	}

	public void setSide(Side side) {
		this.side = side;
	}

	public SideType getSideType() {
		return sideType;
	}

	public void setSideType(SideType sideType) {
		this.sideType = sideType;
	}
	
	
}
